//
//  LXCarEditViewController.m
//  ZuLinProject
//
//  Created by bancheng on 2021/12/30.
//  Copyright © 2021 LX_App. All rights reserved.
//

#import "LXCarEditViewController.h"
#import "LXTableViewCell.h"
#import "CheLiangModel.h"
#import "LXChooseBtnTableViewCell.h"
#import "LXApplyAnnexTableCell.h"
#import "PinPaiModel.h"
#import "LXPhotoHelper.h"
#import "LXRemarkTabelViewCell.h"
@interface LXCarEditViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic) UITableView *tableView;
@property (nonatomic) NSMutableArray *data;
@property (nonatomic) NSMutableDictionary *loanDic;
@property (nonatomic) NSDictionary *selDic;
@property (nonatomic) NSMutableArray *operPlatformData; // 运行平台数据源
@property (nonatomic) NSInteger operPlatform; // 运行平台 （1：滴滴平台，2：美团平台，3：不限平台）
@property (nonatomic) NSMutableArray *leaseCarTypeData; // 车辆类型数据源
@property (nonatomic) NSInteger leaseCarType; // 车辆类型 （1：快车优享，2：专车，3：商务）
@property (nonatomic) NSMutableArray *energyTypeData; // 能源类型数据源
@property (nonatomic) NSInteger energyType; // 能源类型（1：纯电力，2：混合动力，3：燃油动力）
@property (nonatomic) NSString *frontUrl; // 行驶证正面url
@property (nonatomic) NSString *backUrl; // 行驶证背面url
@property (nonatomic) NSString *bevelUrl; // 行驶证斜面url
@property (nonatomic) NSString *carBrand,*carMode; // 品牌车型
@property (nonatomic) NSString *registerTime; // 注册时间
@property (nonatomic) NSMutableArray *annexAry; //  维修图片  展示用
@property (nonatomic) NSMutableArray *annexDataAry; //  维修图片 提交用

@end

@implementation LXCarEditViewController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self layoutCustomNav:self.view title:@"修改车辆信息"];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = White_Color;
    
    NSDictionary *dic = @{
        @"url":@"upLoad_B",
    };
    self.annexAry = [NSMutableArray array];
    self.annexDataAry = [NSMutableArray array];

    if (!StringIsEmpty(self.carModel.carDescripUrl)) {
        NSArray *carDescripUrlAry = [self.carModel.carDescripUrl componentsSeparatedByString:@","];
        for (NSString *url in carDescripUrlAry) {
            [self.annexAry addObject:@{
                        @"url":[NSString stringWithFormat:@"%@%@",HTTP_URL,url],
            }];
            [self.annexDataAry addObject:url];
        }
    }
    
    [self.annexAry addObject:dic];
    
    
   
    
    [self.view addSubview:self.tableView];
    
    [self.tableView registerClass:[LXTableViewCell class] forCellReuseIdentifier:NSStringFromClass([LXTableViewCell class])];
    [self.tableView registerClass:[LXChooseBtnTableViewCell class] forCellReuseIdentifier:NSStringFromClass([LXChooseBtnTableViewCell class])];
    [self.tableView registerClass:[LXApplyAnnexTableCell class] forCellReuseIdentifier:NSStringFromClass([LXApplyAnnexTableCell class])];
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([LXRemarkTabelViewCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([LXRemarkTabelViewCell class])];

    
    
    [self loadData];
    
    
    [self setBottomView];
    
    
}

- (void)loadData{
    
    self.loanDic  = [NSMutableDictionary dictionary];
    //运行平台
    self.operPlatform = [self.carModel.operPlatform intValue];
    //车辆类型
    self.leaseCarType = [self.carModel.leaseCarType intValue];
    //能源性质
    self.energyType = self.carModel.energyType;
  
    
    // 车牌号
    [self.loanDic setValue:self.carModel.carNum forKey:@"carNum"];
    // 品牌
    [self.loanDic setValue:[NSString stringWithFormat:@"%@ %@",self.carModel.carBrand,self.carModel.carMode] forKey:@"carBrand"];
    // 车架号
    [self.loanDic setValue:self.carModel.vinNo forKey:@"vinNo"];
    // 注册日期
   NSInteger registerTime =  [NSString timeSwitchTimestamp:self.carModel.registerTime andFormatter:@"yyyyMMdd"];
   NSString *registerTimeStr = [NSString timestampSwitchTime:registerTime/1000 andFormatter:@"yyyy-MM-dd"];
    [self.loanDic setValue:registerTimeStr forKey:@"registerTime"];
    // 发动机号
    [self.loanDic setValue:self.carModel.engineNo forKey:@"engineNo"];
    // 形式里程
    [self.loanDic setValue:self.carModel.kilometers forKey:@"kilometers"];
    // 年检
    [self.loanDic setValue:self.carModel.yearCheckUpTimeScope forKey:@"yearCheckUpTimeScope"];
    //保险
    [self.loanDic setValue:self.carModel.insureTime forKey:@"insureTime"];

    //运行性质
    [self.loanDic setValue:[Tool getId:self.carModel.carServiceType DicDataWithKey:k_YXXZ] forKey:@"carServiceType"];

    //所有人
    if ([self.carModel.ascription intValue] ==1) {
        [self.loanDic setValue:@"企业" forKey:@"ascription"];
    }
    else {
        [self.loanDic setValue:@"个人" forKey:@"ascription"];
    }
    
    
    [self.loanDic setValue:self.carModel.remark forKey:@"remark"];
    
    
    
    self.data = @[
        @{
            @"title":@"上传车辆照片",
            @"key":@"carPhoto",
            @"height":@(kComAnnexHeight)
        },
        
        @{
            @"title":@"车牌号",
            @"key":@"carNum",
            @"textColor":ColorWithAAAAAA,
            @"detailTextColor":mainColor,
            @"placeHolder" : @"请输入车牌号",
            @"canEdit":@(NO),
            @"showAccess":@(NO),
            @"maxLength":@(8),
            @"sel":@"",
            @"height":@(kComHeight)
        },
        @{
            @"title":@"品牌",
            @"key":@"carBrand",
            @"textColor":ColorWithAAAAAA,
            @"detailTextColor":ColorWithAAAAAA,
            @"placeHolder" : @"请选择品牌型号",
            @"canEdit":@(NO),
            @"showAccess":@(NO),
            @"maxLength":@(1000),
            @"sel":@"",
            @"height":@(kComHeight)
        },
        @{
            @"title":@"车架号",
            @"key":@"vinNo",
            @"placeHolder" : @"请输入车架号",
            @"textColor":ColorWithAAAAAA,
            @"detailTextColor":ColorWithAAAAAA,
            @"canEdit":@(NO),
            @"showAccess":@(NO),
            @"maxLength":@(25),
            @"sel":@"clickIntoTime",
            @"height":@(0.00001)
        },
        @{
            @"title":@"注册日期",
            @"key":@"registerTime",
            @"placeHolder" : @"请选择注册日期",
            @"textColor":ColorWithAAAAAA,
            @"detailTextColor":ColorWithAAAAAA,
            @"canEdit":@(NO),
            @"showAccess":@(NO),
            @"maxLength":@(1000),
            @"sel":@"",
            @"height":@(kComHeight)
        },
        @{
            @"title":@"发动机号",
            @"key":@"engineNo",
            @"placeHolder" : @"请输入发动机号",
            @"textColor":ColorWithAAAAAA,
            @"detailTextColor":ColorWithAAAAAA,
            @"canEdit":@(NO),
            @"showAccess":@(NO),
            @"maxLength":@(25),
            @"sel":@"",
            @"height":@(0.00001)
        },
        @{
            @"title":@"行驶里程(Km)",
            @"key":@"kilometers",
            @"placeHolder" : @"请输入公里数",
            @"canEdit":@(YES),
            @"keyboardType":@(UIKeyboardTypeDecimalPad),
            @"showAccess":@(NO),
            @"maxLength":@(7),
            @"sel":@"",
            @"height":@(kComHeight)
        },
        @{
            @"title":@"年检",
            @"key":@"yearCheckUpTimeScope",
            @"placeHolder" : @"请选择年检日期",
            @"canEdit":@(NO),
            @"showAccess":@(YES),
            @"maxLength":@(1000),
            @"sel":@"clickYearCheckUpTimeScope",
            @"height":@(kComHeight)
        },
        @{
            @"title":@"保险",
            @"key":@"insureTime",
            @"placeHolder" : @"请选择保险日期",
            @"canEdit":@(NO),
            @"keyboardType":@(UIKeyboardTypeDecimalPad),
            @"showAccess":@(YES),
            @"maxLength":@(7),
            @"sel":@"clickInsureTime",
            @"height":@(kComHeight)
        },
        @{
            @"title":@"运行平台",
            @"key":@"operPlatform",
            @"height":@([LXChooseBtnTableViewCell height:self.operPlatformData])
        },
        @{
            @"title":@"车辆类型",
            @"key":@"leaseCarType",
            @"height":@([LXChooseBtnTableViewCell height:self.leaseCarTypeData])
        },
        @{
            @"title":@"能源类型",
            @"key":@"energyType",
            @"height":@([LXChooseBtnTableViewCell height:self.energyTypeData])
        },
        @{
            @"title":@"营运性质",
            @"key":@"carServiceType",
            @"textColor":ColorWithAAAAAA,
            @"detailTextColor":ColorWithAAAAAA,
            @"height":@(kComHeight)
        },
        @{
            @"title":@"所有人",
            @"key":@"ascription",
            @"textColor":ColorWithAAAAAA,
            @"detailTextColor":ColorWithAAAAAA,
            @"height":@(kComHeight)
        },
        @{
            @"title":@"备注",
            @"key":@"remark",
            @"height":@(150)
        },

       
 ].mutableCopy;
    
    
   
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.data.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSDictionary *dic = self.data[indexPath.row];
    
    if ([dic[@"key"] isEqualToString:@"carPhoto"]) {
        return [LXApplyAnnexTableCell getCellHeightWithDataSource:self.annexAry] + 100;
    }
    
    return [dic[@"height"] doubleValue];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    NSDictionary *dic = self.data[indexPath.row];

   
    if ([dic[@"key"] isEqualToString:@"carPhoto"]) {
        LXApplyAnnexTableCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([LXApplyAnnexTableCell class])];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        [cell setClipsToBounds:YES];
        cell.titleLab.text = dic[@"title"];
        cell.subLab.text = @"*上传图片小于1M，支持.jpg/.png格式，最多可上传5张。";
        [cell reloadAnnexData:self.annexAry WithMaxNum:5];
        
        // 添加图片
        [cell setCallBackTakeAnnex:^(NSInteger num) {
            [[LXPhotoHelper shareHelper] showImageViewSelcteWithResultBlock:^(NSDictionary *dic) {
                NSString *imageUrl = [NSString stringWithFormat:@"%@%@",HTTP_URL,dic[@"url"]];
                [self.annexAry insertObject:@{@"url":imageUrl} atIndex:0];
                
                [self.annexDataAry insertObject:dic[@"url"] atIndex:0];
                
                [self.tableView reloadData];
            }];
        }];
        
        
        
        // 放大图片
        [cell setCallBackExtendAnnex:^(NSInteger num,id obj) {
            UIImageView *imageV = (UIImageView*)obj;
            UIWindow *window = [BaseViewController getCurrentWindow];
            ShowBigImageWithFrameView *ImageShow = [[ShowBigImageWithFrameView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, B_HEIGHT) withImage:imageV.image];
            [window addSubview:ImageShow];
            
        }];
        // 删除图片
        [cell setCallBackDeleteAnnex:^(NSInteger num) {
            
            [self.annexAry removeObjectAtIndex:num];
            [self.annexDataAry removeObjectAtIndex:num];
            
            [self.tableView reloadData];
        }];
        
        
        return cell;
    }
   else if ([dic[@"key"] isEqualToString:@"operPlatform"]||
        [dic[@"key"] isEqualToString:@"leaseCarType"]||
        [dic[@"key"] isEqualToString:@"energyType"]) {
       
        
        NSArray *tempAry;
        if ([dic[@"key"] isEqualToString:@"operPlatform"]) {
            tempAry = self.operPlatformData;
        }
        else if ([dic[@"key"] isEqualToString:@"leaseCarType"]) {
            tempAry = self.leaseCarTypeData;
        }
        else if ([dic[@"key"] isEqualToString:@"energyType"]) {
            tempAry = self.energyTypeData;
        }
        
        
       LXChooseBtnTableViewCell *cell = [[LXChooseBtnTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([LXChooseBtnTableViewCell class]) WithData:tempAry];

       cell.selectionStyle = UITableViewCellSelectionStyleNone;
       [cell setClipsToBounds:YES];
        cell.canEdit = YES;
     
       cell.titleLab.text = dic[@"title"];
       [cell setClickBtnBlock:^(NSInteger Id) {
           if ([dic[@"key"] isEqualToString:@"operPlatform"]) {
               self.operPlatform = Id;
           }
           else if ([dic[@"key"] isEqualToString:@"leaseCarType"]) {
               self.leaseCarType = Id;
           }
           else if ([dic[@"key"] isEqualToString:@"energyType"]) {
               self.energyType = Id;
           }
           
       }];
       
       
       
       return cell;
    }
    // 备注
    if([dic[@"key"]  isEqualToString:@"remark"]){
       LXRemarkTabelViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([LXRemarkTabelViewCell class])];
       cell.selectionStyle = UITableViewCellSelectionStyleNone;
       [cell setClipsToBounds:YES];
       cell.textView.placeholder = @"请输入 ~";
       cell.textView.maxLength = 200;
       cell.remarkTitle.text = dic[@"title"];
       cell.textView.text = self.loanDic[dic[@"key"]];
       [cell setTextViewEdit:^(NSString * _Nonnull textStr) {
           self.loanDic[dic[@"key"]]  = textStr;
       }];
       return cell;
   }
    
    
    
    
    
    LXTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([LXTableViewCell class])];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    [cell setClipsToBounds:YES];
    

    cell.cellDic = dic;
    cell.textFiled.hidden = NO;
    cell.subTitleLab.hidden = YES;
    cell.textFiled.text = self.loanDic[dic[@"key"]];
    if ([dic[@"key"] isEqualToString:@"carBrand"] && !StringIsEmpty(self.loanDic[dic[@"key"]])) {
        cell.textFiled.hidden = YES;
        cell.subTitleLab.hidden = NO;
        cell.subTitleLab.text = self.loanDic[dic[@"key"]];
    }
    
    cell.textfiledChangeBlock = ^(NSString * _Nonnull textStr) {
        self.loanDic[dic[@"key"]]  = textStr;
    };
    
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    NSDictionary *dic = self.data[indexPath.row];
    self.selDic = dic;
    NSString * selName = dic[@"sel"];
    SEL action = NSSelectorFromString(selName);
    if ([self respondsToSelector:action]) {
        [self performSelector:action withObject:nil afterDelay:0];
    }

}

#pragma mark -- 选择注册日期
-(void)clickRegisterTime{
    [self.view endEditing:YES];
    DatePickView *datePicker =[[DatePickView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight) withDateStr:self.loanDic[@"registerTime"] withIsMaxDate:YES withNoForward:NO WithTips:@"请选择注册日期"] ;
    [datePicker showBoomView];
    [[[UIApplication sharedApplication].delegate window] addSubview:datePicker];
    WEAKSELF
    datePicker.block = ^(NSString *yearString){
        [weakSelf.loanDic setObject:yearString forKey:weakSelf.selDic[@"key"]];
        [weakSelf.tableView reloadData];
    };
}

#pragma mark -- 选择年检日期
-(void)clickYearCheckUpTimeScope{
    [self.view endEditing:YES];
    DatePickView *datePicker =[[DatePickView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight) withDateStr:self.loanDic[@"yearCheckUpTimeScope"] withIsMaxDate:YES withNoForward:NO WithTips:@"请选择年检日期"] ;
    [datePicker showBoomView];
    [[[UIApplication sharedApplication].delegate window] addSubview:datePicker];
    WEAKSELF
    datePicker.block = ^(NSString *yearString){
        [weakSelf.loanDic setObject:yearString forKey:weakSelf.selDic[@"key"]];
        [weakSelf.tableView reloadData];
    };
}
#pragma mark -- 选择保险日期
-(void)clickInsureTime{
    [self.view endEditing:YES];
    DatePickView *datePicker =[[DatePickView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight) withDateStr:self.loanDic[@"insureTime"] withIsMaxDate:YES withNoForward:NO WithTips:@"请选保险日期"] ;
    [datePicker showBoomView];
    [[[UIApplication sharedApplication].delegate window] addSubview:datePicker];
    WEAKSELF
    datePicker.block = ^(NSString *yearString){
        [weakSelf.loanDic setObject:yearString forKey:weakSelf.selDic[@"key"]];
        [weakSelf.tableView reloadData];
    };
}


- (NSMutableArray *)data{
    if (!_data) {
        _data = [[NSMutableArray alloc]init];
    }
    return _data;
}

- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, LL_StatusBarAndNavigationBarHeight, ScreenWidth, kScreenHeight - LL_StatusBarAndNavigationBarHeight - kComHeight) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.contentInset = UIEdgeInsetsMake(0,0,kComHeight + 10,0);
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        
    }
    return _tableView;
}
-(void)setBottomView{
    

    UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(15, kScreenHeight - kComHeight - 10, kScreenWidth - 30, kComHeight)];
    btn.backgroundColor = mainColor;
    btn.layer.cornerRadius = 3;
    btn.layer.masksToBounds = YES;
    btn.tag = 2;
    [btn setTitle:@"确认修改" forState:UIControlStateNormal];
    [btn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    btn.titleLabel.font = Fond16;
    [[BaseViewController getCurrentVC].view addSubview:btn];
    [btn addTarget:self action:@selector(clickBottomView:) forControlEvents:UIControlEventTouchUpInside];
    
    
}

-(void)clickBottomView:(UIButton *)sender{
    

    if (StringIsEmpty(self.loanDic[@"kilometers"])){
        showAlert(@"行驶里程不能为空");
        return;
    }
    if (StringIsEmpty(self.loanDic[@"yearCheckUpTimeScope"])){
        showAlert(@"年检时间不能为空");
        return;
    }
    if (StringIsEmpty(self.loanDic[@"insureTime"])){
        showAlert(@"保险时间不能为空");
        return;
    }
   
    
    NSString *carUrl = [self.annexDataAry componentsJoinedByString:@","];

    NSDictionary *dic = @{
        @"id":self.carModel.ID,// 车辆id
        @"kilometers":self.loanDic[@"kilometers"],// 行驶里程
        @"operPlatform":@(self.operPlatform),//运行平台
        @"leaseCarType":@(self.leaseCarType),//车辆类型
        @"energyType":@(self.energyType),//能源类型
        @"carDescripUrl":carUrl,
        @"yearCheckUpTimeScope":self.loanDic[@"yearCheckUpTimeScope"],//年检
        @"insureTime":self.loanDic[@"insureTime"],//保险
        @"remark":self.loanDic[@"remark"],
        
    };

    [Tool showAlertTitle:@"您确定修改车辆信息吗?" msg:@"" cancelTitle:@"取消" commitBtnTitle:@"确定" cancelHandlerBlock:^{
    } commitHandlerBlock:^{
        [MSNetworkManager postRevertUrl:TCarUpdate_URL params:dic success:^(id  _Nonnull paginationObj, id  _Nonnull resonseObj, BOOL isSuccess, NSString * _Nonnull message) {
            if (isSuccess) {
                showAlert(@"车辆修改成功");
                [self.navigationController popViewControllerAnimated:YES];
                [self.navigationController popViewControllerAnimated:YES];
            }
        } failure:^(NSUInteger code, NSString * _Nonnull message) {
            
        } withShowHud:YES];
    } onVC:self];
  

    
}

#pragma mark --  能源类型数据源
- (NSArray *)energyTypeData{
    
//    _energyTypeData = @[
//
//        @{
//            @"title":@"纯电动",
//            @"sel":@(NO),
//            @"id":@"1"
//        }.mutableCopy,
//        @{
//            @"title":@"混合动力",
//            @"sel":@(NO),
//            @"id":@"2"
//        }.mutableCopy,
//        @{
//            @"title":@"燃油动力",
//            @"sel":@(NO),
//            @"id":@"3"
//        }.mutableCopy,
//    ];
//    for (NSMutableDictionary *dic in _energyTypeData) {
//        if ([dic[@"id"] intValue] == self.energyType) {
//            [dic setValue:@(YES) forKey:@"sel"];
//            break;
//        }
//    }
//    return _energyTypeData;
    
    
    NSArray *energeTypeAry = [[NSUserDefaults standardUserDefaults] valueForKey:k_NYLX];
    
    _energyTypeData = [NSMutableArray array];

    if (!ObjectIsEmpty(energeTypeAry)) {
        
        for (int i = 0; i<energeTypeAry.count; i++) {
            
            NSDictionary *mm = energeTypeAry[i];
            NSDictionary *dic = @{
                @"title":mm[@"label"],
                @"sel":@(NO),
                @"id":mm[@"value"],
            }.mutableCopy;
            [_energyTypeData addObject:dic];
        }
    }

    for (NSMutableDictionary *dic in _energyTypeData) {
        if ([dic[@"id"] intValue]==self.energyType) {
            [dic setValue:@(YES) forKey:@"sel"];
            break;
        }
    }
    return _energyTypeData;
    
    
}
#pragma mark -- 车辆类型数据源
- (NSArray *)leaseCarTypeData{
    
    
    NSArray *carTypeAry = [[NSUserDefaults standardUserDefaults] valueForKey:k_CLLX];
    
    _leaseCarTypeData = [NSMutableArray array];

    if (!ObjectIsEmpty(carTypeAry)) {
        
        for (int i = 0; i<carTypeAry.count; i++) {
            
            NSDictionary *mm = carTypeAry[i];
            NSDictionary *dic = @{
                @"title":mm[@"label"],
                @"sel":@(NO),
                @"id":mm[@"value"],
            }.mutableCopy;
            [_leaseCarTypeData addObject:dic];
        }
    }

    for (NSMutableDictionary *dic in _leaseCarTypeData) {
        if ([dic[@"id"] intValue]==self.leaseCarType) {
            [dic setValue:@(YES) forKey:@"sel"];
            break;
        }
    }
    return _leaseCarTypeData;
}
#pragma mark -- 运行平台数据源
- (NSArray *)operPlatformData{
    
    
    NSArray *operPlatformAry = [[NSUserDefaults standardUserDefaults] valueForKey:k_YXPT];
    
    _operPlatformData = [NSMutableArray array];

    if (!ObjectIsEmpty(operPlatformAry)) {
        
        for (int i = 0; i<operPlatformAry.count; i++) {
            
            NSDictionary *mm = operPlatformAry[i];
            NSDictionary *dic = @{
                @"title":mm[@"label"],
                @"sel":@(NO),
                @"id":mm[@"value"],
            }.mutableCopy;
            [_operPlatformData addObject:dic];
        }
    }
    
 
    for (NSMutableDictionary *dic in _operPlatformData) {
        if ([dic[@"id"] intValue] == self.operPlatform) {
            [dic setValue:@(YES) forKey:@"sel"];
            break;
        }
    }
    return _operPlatformData;
}
@end
